package com.codedancer.campus.manager.api.common;

import com.codedancer.campus.common.core.BaseApi;
import com.codedancer.campus.common.response.ApiResponse;
import com.codedancer.campus.manager.service.ICommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/common")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE,
    RequestMethod.PUT}, maxAge = 3600)
@Api(value = "公共Api", description = "公共Api", tags = "公共Api")
public class CommonApi extends BaseApi {

    @Autowired
    private ICommonService commonService;

    @PostMapping("/upload-image")
    @ApiOperation("上传图片")
    public ApiResponse<String> uploadImage(@RequestParam("image") MultipartFile image){
        return success(commonService.uploadImage(image));
    }
}
